package com.zhifei.web.controller.project;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhifei.common.utils.Constant;
import com.zhifei.common.utils.DateUtils;
import com.zhifei.common.utils.Result;
import com.zhifei.system.domain.vo.*;
import com.zhifei.system.service.DingUserArchivesService;
import com.zhifei.system.service.PersonProjectService;
import com.zhifei.system.util.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/personProject")
@Api(tags="项目制人力管理")
public class PersonProjectController {

    @Autowired
    private PersonProjectService personProjectService;
    @Autowired
    private DingUserArchivesService dingUserArchivesService;

    @GetMapping("page")
    @ApiOperation("分页项目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.PAGE, value = "当前页码，从1开始", paramType = "query", required = true, dataType="int", defaultValue = "1") ,
            @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int", defaultValue = "10"),
            @ApiImplicitParam(name = "customerName", value = "客户名称", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderNo", value = "订单编号", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderStartDate", value = "下单开始时间", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orderEndDate", value = "下单结束时间", required = false, paramType = "query", dataType = "String")
    })
    public Result<Page<PersonProjectVo>> page(@ApiIgnore @RequestParam Map<String, Object> params){
        PageUtils page = personProjectService.queryPage(params);
        return Result.success(page);
    }

    @GetMapping("pageUser")
    @ApiOperation("分页项目成员列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.PAGE, value = "当前页码，从1开始", paramType = "query", required = true, dataType="int", defaultValue = "1") ,
            @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int", defaultValue = "10"),
            @ApiImplicitParam(name = "deptId", value = "部门id", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "userStatus", value = "状态（1-在项；2-离职；）", paramType = "query", required = false, dataType = "String")
    })
    public Result<Page<PersonProjectUserVo>> pageUser(@ApiIgnore @RequestParam Map<String, Object> params){
        PageUtils page = personProjectService.pageUser(params);
        return Result.success(page);
    }

    @GetMapping("pageUserArchives")
    @ApiOperation("分页项目成员每月档案列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.PAGE, value = "当前页码，从1开始", paramType = "query", required = true, dataType="int", defaultValue = "1") ,
            @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int", defaultValue = "10"),
            @ApiImplicitParam(name = "deptId", value = "部门id", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "userStatus", value = "状态（1-在项；2-离职；）", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "monthStartDate", value = "月份开始时间", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "monthEndDate", value = "月份结束时间", required = false, paramType = "query", dataType = "String")
    })
    public Result<Page<PersonProjectUserArchivesVo>> pageUserArchives(@ApiIgnore @RequestParam Map<String, Object> params){
        PageUtils page = dingUserArchivesService.pageUserArchives(params);
        return Result.success(page);
    }

    @GetMapping("getUserArchivesSummary")
    @ApiOperation("项目成员每月档案汇总")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deptId", value = "部门id", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "userStatus", value = "状态（1-在项；2-离职；）", paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(name = "monthStartDate", value = "月份开始时间", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "monthEndDate", value = "月份结束时间", required = false, paramType = "query", dataType = "String")
    })
    public Result<UserArchivesSummaryVo> getUserArchivesSummary(@ApiIgnore @RequestParam Map<String, Object> params){
        UserArchivesSummaryVo vo = dingUserArchivesService.getUserArchivesSummary(params);
        return Result.success(vo);
    }

}


